package com.aiowang.springboot.single.activemq.example.jms;

import com.aiowang.springboot.single.activemq.interfaces.SingleActiveMQTransportListener;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * @author aiowang
 * @date 2020-03-23 21:41
 */
@Component
public class MyTransportListener implements SingleActiveMQTransportListener {
    /**
     * 对消息传输命令进行监控
     * @param object
     * @param activeMQSeverName 当前服务名
     */
    @Override
    public void onCommand(Object object, String activeMQSeverName) {

    }

    /**
     * 对监控到的异常进行触发
     * @param error 错误
     * @param activeMQSeverName 服务名
     */
    @Override
    public void onException(IOException error, String activeMQSeverName) {

    }

    /**
     * 当failover断开时触发
     */
    @Override
    public void transportInterupted(String activeMQSeverName) {

        System.out.println("transportInterupted--" + activeMQSeverName);
    }


    /**
     * 监控到failover恢复后进行触发
     */
    @Override
    public void transportResumed(String activeMQSeverName) {
        System.out.println(activeMQSeverName);
    }
}
